<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">

<title>class MarcconverterController - Rails Application Documentation</title>

<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
</script>

<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="./index.html">Home</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>app/controllers/marcconverter_controller.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link"><a href="ApplicationController.html">ApplicationController</a>
  
</nav>

    
    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-i-convert">#convert</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="./doc/README_FOR_APP.html">README_FOR_APP</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="./MarcTools.html">MarcTools</a>
  
    <li><a href="./MarcTools/MarcConverter.html">MarcTools::MarcConverter</a>
  
    <li><a href="./ApplicationController.html">ApplicationController</a>
  
    <li><a href="./ApplicationHelper.html">ApplicationHelper</a>
  
    <li><a href="./CzController.html">CzController</a>
  
    <li><a href="./MarcconverterController.html">MarcconverterController</a>
  
    <li><a href="./Object.html">Object</a>
  
    <li><a href="./OracleController.html">OracleController</a>
  
    <li><a href="./PersonController.html">PersonController</a>
  
    <li><a href="./PersonHelper.html">PersonHelper</a>
  
    <li><a href="./RsqvHelper.html">RsqvHelper</a>
  
    <li><a href="./RsqvpreviewController.html">RsqvpreviewController</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class MarcconverterController</h1>

  <div id="description" class="description">
    
  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    

    <!-- Methods -->
    
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-convert" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">convert</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          
          

          
          <div class="method-source-code" id="convert-source">
            <pre><span class="ruby-comment"># File app/controllers/marcconverter_controller.rb, line 5</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">convert</span>
    <span class="ruby-identifier">require</span> <span class="ruby-string">'MarcTools'</span>
    <span class="ruby-identifier">rismid</span>=<span class="ruby-string">&quot;000072450&quot;</span>
        <span class="ruby-identifier">dn</span> =<span class="ruby-string">'dn:http://www.loc.gov/MARC21/slim'</span>
        <span class="ruby-identifier">xml_document</span> = <span class="ruby-constant">LibXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">file</span>(<span class="ruby-string">'/home/stephan/RSQV/cz.xml'</span>)
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-string">&quot;extext&quot;</span>]
          <span class="ruby-identifier">rismid</span>=<span class="ruby-identifier">params</span>[<span class="ruby-string">&quot;extext&quot;</span>][<span class="ruby-string">&quot;name&quot;</span>]
        <span class="ruby-keyword">end</span>
   
          
          
        <span class="ruby-identifier">book_xpath</span> = <span class="ruby-string">'//dn:record/dn:controlfield[@tag=&quot;001&quot;][contains(.,&quot;'</span><span class="ruby-operator">+</span><span class="ruby-identifier">rismid</span><span class="ruby-operator">+</span><span class="ruby-string">'&quot;)]/..'</span>
        <span class="ruby-ivar">@ids</span>=<span class="ruby-identifier">xml_document</span>.<span class="ruby-identifier">find</span>(<span class="ruby-string">'//dn:record/dn:controlfield[@tag=&quot;001&quot;]/text()'</span>,<span class="ruby-identifier">dn</span>).<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">shuffle</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">6</span>]
  
               
    <span class="ruby-ivar">@old_xml</span>=<span class="ruby-identifier">xml_document</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">book_xpath</span>,<span class="ruby-identifier">dn</span>)[<span class="ruby-value">0</span>]

    <span class="ruby-identifier">converter</span>=<span class="ruby-constant">MarcTools</span><span class="ruby-operator">::</span><span class="ruby-constant">MarcConverter</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">marc_to_hash</span>(<span class="ruby-ivar">@old_xml</span>)
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">updateElements</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'031$a'</span>, <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]})
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">updateElements</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'031$b'</span>, <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]})
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">updateElements</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'031$c'</span>, <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]})
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">updateElements</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'100$a'</span>, <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>  <span class="ruby-identifier">a</span>[<span class="ruby-value">-1</span>]<span class="ruby-operator">==</span><span class="ruby-string">','</span> <span class="ruby-operator">?</span>   <span class="ruby-identifier">a</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>] <span class="ruby-operator">:</span>  <span class="ruby-identifier">a</span>})
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">updateElements</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'700$a'</span>, <span class="ruby-identifier">lambda</span>  { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>  <span class="ruby-identifier">a</span>[<span class="ruby-value">-1</span>]<span class="ruby-operator">==</span><span class="ruby-string">','</span> <span class="ruby-operator">?</span>   <span class="ruby-identifier">a</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>] <span class="ruby-operator">:</span>  <span class="ruby-identifier">a</span>})
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">updateElements</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'240$a'</span>, <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>  <span class="ruby-identifier">a</span>[<span class="ruby-value">-1</span>]<span class="ruby-operator">==</span><span class="ruby-string">','</span> <span class="ruby-operator">?</span>   <span class="ruby-identifier">a</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>] <span class="ruby-operator">:</span>  <span class="ruby-identifier">a</span>})
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">changeTag</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'246'</span>, <span class="ruby-string">'730'</span>) 
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">changeTag</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'080'</span>, <span class="ruby-string">'500'</span>)
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">changeTag</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'910'</span>, <span class="ruby-string">'852'</span>)
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">insertTag</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'852$a'</span>, <span class="ruby-string">'CZ-Bu'</span>)

<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'500$2'</span>,<span class="ruby-string">'500$a'</span>)

<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">changeSubfieldCode</span>(<span class="ruby-ivar">@marc_hash</span>,<span class="ruby-string">'500$2'</span>,<span class="ruby-string">'500$a'</span>)
<span class="ruby-ivar">@marc_hash</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">filter</span>(<span class="ruby-ivar">@marc_hash</span>, <span class="ruby-node">%w[ 031$2 100$7 655$2 008 007 100$4 500$2 650$2 700$7 ]</span>)
    <span class="ruby-ivar">@new_xml</span>=<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">hash_to_marc</span>(<span class="ruby-ivar">@marc_hash</span>)
  <span class="ruby-keyword">end</span></pre>
          </div><!-- convert-source -->
          
        </div>

        

        
      </div><!-- convert-method -->

    
    </section><!-- public-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.2.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

